﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TeamDeploy.Activities
{
    internal class Utility
    {
        public static bool DebugLogging 
        {
            get
            {
                return _debugLogging;
            }
            set
            {
                _debugLogging = value;
            }
        }
        private static bool _debugLogging = false;

        internal static void LogMessage(string message)
        {
            if (_debugLogging == false)
                return;

            DateTime dt = DateTime.Now;
            String filePath = Path.Combine(Path.GetTempPath(),"TeamDeploy" + dt.ToString("yyyyMMdd") + ".log");
            if (!File.Exists(filePath))
            {
                FileStream fs = File.Create(filePath);
                fs.Close();
            }
            try
            {
                StreamWriter sw = File.AppendText(filePath);
                sw.WriteLine(dt.ToString("hh:mm:ss") + "|" + message);
                sw.Flush();
                sw.Close();
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
